var mainSideFixed;
var scrollTop;
// -完成度百分比-------------------------------------------------------------------------------------------------------------------------
//completion 数组中的 1 代表已经完成 0代表未完成
var completionArr = [1,1,0,0,0,0,0,0,0,0,0];
$(function(){
    //滚动条
    mainSideFixed=$("#mainSideFixed").offset().top;
    $(window).scroll(function(){
        scrollTop = $(document).scrollTop();
        if(scrollTop>=mainSideFixed){
            $("#mainSideFixed").css("position","fixed");
            $("#mainSideFixed").css({'top':0});
        }else{
            $("#mainSideFixed").css('position','');
            $("#mainSideFixed").css({'top':0});
        }
    });
    //设置完成度数组
    if(mainCon.find('.selfEvaluationCon').find('.con').html() != ''){
        completionArr[2] = 1;
    }
    if(mainCon.find('.worker').find('.workerCon').find('.listCon').length > 0 ){
        completionArr[3] = 1;
    }
    if(mainCon.find('.education').find('.educationCon').find('.listCon').length > 0 ){
        completionArr[4] = 1;
    }
    if(mainCon.find('.project').find('.projectCon').find('.listCon').length > 0 ){
        completionArr[5] = 1;
    }
    if(mainCon.find('.language').find(".languageCon").find('.listItem').find('li').length > 0){
        completionArr[6] = 1;
    }
    if(mainCon.find('.skill').find(".skillCon").find('.listItem').find('li').length > 0){
        completionArr[7] = 1;
    }
    if(mainCon.find('.certificate').find(".certificateCon").find('.listItem').find('li').length > 0){
        completionArr[8] = 1;
    }
    if(mainCon.find('.other').find(".otherCon").find('.listCon').length > 0){
        completionArr[9] = 1;
    }
    if(mainCon.find('.works').find(".worksCon").find('.listCon').find('li').length > 0){
        completionArr[10] = 1;
    }
    completion(0,1);
});

/* completion 数组中的 1 代表已经完成 0代表未完成
 * few 当前第几个完成度
 ** fewVal 当前完成度完成 0 代表未完成 1 代表完成
 */
function  completion(few,fewVal){
    completionArr[few] = fewVal;
    var mainSide = $("#mainSide");
    mainSide.find('.sList').find('li').each(function(index){
        var othis = $(this);
        if(completionArr[index] == 0){
            othis.removeClass('suc').addClass('add');
        }else if(completionArr[index] == 1){
            othis.removeClass('add').addClass('suc');
        }
    });

    //百分比
    var percentage = 0;
    for(var i=0;i<11;i++){
        if(i == 8 || i == 9){
            if(completionArr[i] == 1){
                percentage += 5;
            }
        }else{
            if(completionArr[i] == 1){
                percentage += 10;
            }
        }
    }
    //设置背景完成百分比
    switch (percentage){
        case 10 : mainSide.find('.percentage').css({'background-position':'-128px 0px'}); break;
        case 20 : mainSide.find('.percentage').css({'background-position':'-512px 0px'}); break;
        case 25 : mainSide.find('.percentage').css({'background-position':'-640px 0px'}); break;
        case 30 : mainSide.find('.percentage').css({'background-position':'0px -128px'}); break;
        case 35 : mainSide.find('.percentage').css({'background-position':'-128px -128px'}); break;
        case 40 : mainSide.find('.percentage').css({'background-position':'-256px -128px'}); break;
        case 45 : mainSide.find('.percentage').css({'background-position':'-384px -128px'}); break;
        case 50 : mainSide.find('.percentage').css({'background-position':'-512px -128px'}); break;
        case 55 : mainSide.find('.percentage').css({'background-position':'-640px -128px'}); break;
        case 60 : mainSide.find('.percentage').css({'background-position':'0px -256px'}); break;
        case 65 : mainSide.find('.percentage').css({'background-position':'-128px -256px'}); break;
        case 70 : mainSide.find('.percentage').css({'background-position':'-256px -256px'}); break;
        case 75 : mainSide.find('.percentage').css({'background-position':'-384px -256px'}); break;
        case 80 : mainSide.find('.percentage').css({'background-position':'-512px -256px'}); break;
        case 85 : mainSide.find('.percentage').css({'background-position':'-640px -256px'}); break;
        case 90 : mainSide.find('.percentage').css({'background-position':'0px -384px'}); break;
        case 95 : mainSide.find('.percentage').css({'background-position':'-128px -384px'}); break;
        case 100 : mainSide.find('.percentage').css({'background-position':'-256px -384px'}); break;
        default:mainSide.find('.percentage').css({'background-position':'0px 0px'});
    }
}

